﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DingReving;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.IBusiness;
using Coldairarrow.IBusiness.DTO;
using Coldairarrow.Util;
using Coldairarrow.Util.ClassLibrary;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_TransportBillController : BaseApiController
    {
        #region DI
        private readonly ParameterOptions _parameterOptions;//阈值

        public PB_TransportBillController(IPB_TransportBillBusiness pB_TransportBillBus, IOptions<ParameterOptions> parameterOptions)
        {
            _pB_TransportBillBus = pB_TransportBillBus;
            _parameterOptions = parameterOptions.Value;
        }
        IPB_TransportBillBusiness _pB_TransportBillBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_TransportBillDTO>> GetDataList(PageInput<BilldConditionDTO> input)
        {
            return await _pB_TransportBillBus.GetDataListAsync(input);
        }

        /// <summary>
        /// 获取进厂离厂车辆信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_TransportBillDTO>> GetBilDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_TransportBillBus.GetBilDataListAsync(input);
        }

        /// <summary>
        /// 车辆过磅
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_TransportBillDTO>> GetBilVehicleWeighing(PageInput<BilldConditionDTO> input)
        {
            return await _pB_TransportBillBus.GetBilVehicleWeighingAsync(input);
        }

        [HttpPost]
        public async Task<List<RelevantCodeDTO>> GetRelevantCode(PageInput<RelevantCodeConditionDTO> input)
        {
            
            return await _pB_TransportBillBus.GetRelevantCodeDataListAsync(input);
        }
        /// <summary>
        /// 打印派车单
        /// </summary>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_TransportBilllistinfo>> GetDataListInfo(string ParentId) {
            var res = await _pB_TransportBillBus.GetDataListInfo(ParentId);
            return res;
        }

        [HttpPost]
        public async Task<PB_TransportBill> GetTheData(IdInputDTO input)
        {
            //return await _pB_TransportBillBus.GetTheDataAsync(input.id);
            return await _pB_TransportBillBus.GetTheDataAndPB_Vehicle(input.id);
        }
        [HttpPost]
        public async Task<PB_ChecklistDto> GetChecklist(string id) {

            return await _pB_TransportBillBus.GetChecklist(id);
        }

        /// <summary>
        /// 获取车辆信息
        /// </summary>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_TransportBillVehicleDTO>> GetCarInformation(string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetCarInformationAsync(deptId, BillType);
        }

        /// <summary>
        /// 大屏显示当日发货的车辆动态信息
        /// </summary>
        /// <param name="Days">到今天的天数。-1表示昨天。默认为0</param>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<PB_TransportBillVehicleStateDTO>> GetTodayCarInformation(int Days=0)
        {
            return await _pB_TransportBillBus.GetTodayCarInformationAsync(Days);
        }
        /// <summary>
        /// 大屏显示七日发货数量
        /// </summary>
        /// <param name="Days">到今天的天数。-1表示昨天。默认为0</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PB_TransportBill7DaySend> SevenDaysDeliveryAmount(int Days=7)
        {
            return await _pB_TransportBillBus.GetSevenDaysDeliveryAmount(Days);
        }
        /// <summary>
        /// 大屏显示装车监控照片
        /// </summary>
        /// <param name="Days">到今天的天数。-1表示昨天。默认为0</param>
        /// <returns>｛"value":"url"｝</returns>
        [HttpPost]
        [NoCheckJWT]
        public Task<List<PB_DeliveryPlanValueDTO>> GetTransportMonitor(int Days=0)
        {
            return _pB_TransportBillBus.GetTransportMonitor(Days);
        }
        /// <summary>
        /// 大屏显示30天发货省份和数量
        /// </summary>
        /// <param name="Days">测试扩展天数</param>
        /// <returns>发货省份和数量</returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<ScreenDisplayPieGraphDTO>> Get30DayDeliveryCity(int Days=0)
        {
            return await _pB_TransportBillBus.Get30DayDeliveryCity(Days);
        }
        /// <summary>
        /// 大屏显示30天发货数量
        /// </summary>
        /// <param name="Days">测试扩展天数</param>
        /// <returns>发货数量</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValueDTO Get30DayDeliveryNums(int Days=0)
        {
            return _pB_TransportBillBus.Get30DayDeliveryNums(Days);
        }
        /// <summary>
        /// 大屏显示当月发货数量
        /// </summary>
        /// <param name="Month">前第几月</param>
        /// <returns>当月发货数量</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValueDTO GetMonthDeliveryNums(int Month=0)
        {
            return _pB_TransportBillBus.GetMonthDeliveryNums(Month);
        }
        /// <summary>
        /// 大屏显示发货城市
        /// </summary>
        /// <returns>['新乡市',[[{name: '新乡市'}, {name: '新乡市', value: 200, dataInfo: 发货总数:2000件 }], [{name: '新乡市'}, {name: '呼和浩特市', value: 100, dataInfo: 发货数:1000件 }], [{name: '新乡市'}, {name: '成都市', value: 100, dataInfo: 发货数:1000件 }]]]</returns>
        [HttpPost]
        [NoCheckJWT]        
        public async Task<List<List<object>>> GetDeliveryCity()
        {
            return await _pB_TransportBillBus.GetDeliveryCity();
        }
        /// <summary>
        /// 大屏显示全国爬架总量统计(机位)柱状图
        /// </summary>
        /// <returns>全国爬架总量统计(机位)</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayBarChartDTO GetStandsNumberOrderByCity()
        {
            return _pB_TransportBillBus.GetStandsNumberOrderByCity();
        }
        /// <summary>
        /// 大屏显示发出机位总数
        /// </summary>
        /// <returns>发出机位总数</returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValueDTO GetDeliveryStandsNumber()
        {
            return _pB_TransportBillBus.GetDeliveryStandsNumber();
        }
        /// <summary>
        /// 大屏显示当月发出机位总数
        /// </summary>
        /// <param name="Month">前第几月</param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public ScreenDisplayValueDTO GetMonthDeliveryStandsNumber(int Month=0)
        {
            return _pB_TransportBillBus.GetMonthDeliveryStandsNumber(Month);
        }
        /// <summary>
        /// 根据车牌获取车辆信息
        /// </summary>
        /// <param name="BillId">派车单Id</param>
        /// <param name="plateno">车牌</param>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDetailDTO> GetTransportBillData(string BillId, string plateno, string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetTransportBillDataAsync(BillId, plateno, deptId, BillType);
        }

        /// <summary>
        /// 删除车辆已装车的明细
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteBillDataDetail(PB_TransportBillDetailListData data)
        {
            await _pB_TransportBillBus.DeleteBillDataDetailAsync(data);
        }

        /// <summary>
        /// 装车
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddTransportBillDetail(PB_TransportBillDetailDTO data)
        {
            await _pB_TransportBillBus.AddTransportBillDetailAsync(data);
        }

        /// <summary>
        /// 装车扫描包根据备货单获取包信息
        /// </summary>
        /// <param name="PackQrCode">包二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <param name="BillId">派车单Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TranBillPackDTO> GetTranBillPackData(string PackQrCode, string stockupQrCode, string BillId)
        {
            return await _pB_TransportBillBus.GetTranBillPackDataAsync(PackQrCode, stockupQrCode, BillId);
        }

        /// <summary>
        /// 装车扫描单个成品获取物料数量
        /// </summary>
        /// <param name="BillId">派车单Id</param>
        /// <param name="JobQrCode">单个成品二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TranBillMaterialDTO> GetTranBillMaterialAsync(string BillId, string JobQrCode, string stockupQrCode)
        {
            return await _pB_TransportBillBus.GetTranBillMaterialAsync(BillId, JobQrCode, stockupQrCode);
        }
        /// <summary>
        /// 收货扫描单个成品码获取装车物料数量
        /// </summary>
        /// <param name="BillId"></param>
        /// <param name="JobQrCode"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TranBillAcceptancelDTO> GetAcceptanceMateral(string BillId, string JobQrCode) {
            return await _pB_TransportBillBus.GetAcceptanceMateral(BillId, JobQrCode);
        }
        /// <summary>
        /// 装车扫描单个物料
        /// </summary>
        /// <param name="BillId">车辆Id</param>
        /// <param name="qrcode">单个物料二维码</param>
        /// <param name="stockupQrCode">备货单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PickListMaterialDTO> GetMaterialData(string BillId, string qrcode, string stockupQrCode)
        {
            return await _pB_TransportBillBus.GetMaterialDataAsync(BillId, qrcode, stockupQrCode);
        }

        /// <summary>
        /// 完成装车
        /// </summary>
        /// <param name="billId">车id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task CompleteTransportBillAsync(string billId)
        {
            await _pB_TransportBillBus.CompleteTransportBillAsync(billId);
        }

        /// <summary>
        /// 完成装车并保存装车图片
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SubmitBillImgs(PB_TransportBillImgDTO data)
        {
            await _pB_TransportBillBus.SubmitBillImgsAsync(data);
        }

        /// <summary>
        /// 审核车辆获取车辆详细信息
        /// </summary>
        /// <param name="id">车id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDTO> GetBillData(string id)
        {
            return await _pB_TransportBillBus.GetBillDataAsync(id);
        }
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDTO> GetBilDataListAsyncids(string id)
        {
            return await _pB_TransportBillBus.GetBillDataAsyncids(id);
        }
        /// <summary>
        /// 车俩审核
        /// </summary>
        /// <param name="id">车Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task SubmitBillData(string id)
        {

            double Threshold = Convert.ToDouble(_parameterOptions.Weight);
            await _pB_TransportBillBus.SubmitBillDataAsync(id, Threshold);
        }

        /// <summary>
        /// 验收获取车辆明细信息
        /// </summary>
        /// <param name="billqrcode">派车单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDTO> GetBillListData(string billqrcode)
        {
            return await _pB_TransportBillBus.GetBillListDataAsync(billqrcode);
        }

        /// <summary>
        /// 获取车辆对应的项目信息
        /// </summary>
        /// <param name="billqrcode">派车单二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<BillProjectDTO>> GetBillProjectList(string billqrcode)
        {
            return await _pB_TransportBillBus.GetBillProjectListAsync(billqrcode);
        }
        [HttpPost]
        public async Task<int> Threshold() {
            int Thresholds = Convert.ToInt32(_parameterOptions.Weight);
            return await _pB_TransportBillBus.GetThreshold(Thresholds);
        }

        /// <summary>
        /// 卸车扫描包信息
        /// </summary>
        /// <param name="billqrcode">车辆二维码</param>
        /// /// <param name="packqrcode"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UnloadPackDatas(string billqrcode, string packqrcode)
        {
            await _pB_TransportBillBus.UnloadPackDatasAsync(billqrcode, packqrcode);
        }

        /// <summary>
        /// 验收卸车扫描包信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UnloadPackData(BillDetailDTO data)
        {
            await _pB_TransportBillBus.UnloadPackDataAsync(data);
        }

        /// <summary>
        /// 验收扫描单个物料
        /// </summary>
        /// <param name="billId">派车单Id</param>
        /// <param name="qrcode">单个物料二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TransportBillDetailMaterialDTO> GetReceMaterialData(string billId, string qrcode)
        {
            return await _pB_TransportBillBus.GetReceMaterialDataAsync(billId, qrcode);
        }

        /// <summary>
        /// 现场验收明细信息
        /// </summary>
        /// <param name="billqrcode">派车单二维码</param>
        /// <param name="ProjectId">项目Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDetailDTO> GetBillReceDetailData(string billqrcode, string ProjectId,string BudingId)
        {
            return await _pB_TransportBillBus.GetBillReceDetailDataAsync(billqrcode, ProjectId, BudingId);
        }

        /// <summary>
        /// 现场验收明细移除
        /// </summary>
        /// <param name="data"></param>
        /// <param name="billId">派车单Id</param>
        /// <param name="ProjectId">项目Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteBillReceDetailData(PB_TransportBillDetailListData data, string billId, string ProjectId)
        {
            await _pB_TransportBillBus.DeleteBillReceDetailDataAsync(data, billId, ProjectId);
        }

        /// <summary>
        /// 卸车提交
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task CheckBillsData(CheckBillDTO data)
        {
            await _pB_TransportBillBus.CheckBillDatasAsync(data);
        }



        /// <summary>
        /// 车俩验收卸车提交
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task CheckBillData(CheckBillDTO data)
        {
            await _pB_TransportBillBus.CheckBillDataAsync(data);
        }

        /// <summary>
        /// 车俩验收
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task CheckBill(CheckBillDTO data)
        {
            await _pB_TransportBillBus.CheckBillAsync(data);
        }


        /// <summary>
        /// 车辆毛重超载卸车获取车辆信息
        /// </summary>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>

        [HttpPost]
        public async Task<List<PB_TransportBillVehicleDTO>> GetUnloadCarInformationAsync(string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetUnloadCarInformationAsync(deptId, BillType);
        }

        /// <summary>
        /// 车辆毛重超载卸车
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BillUnloadDTO> UnloadTransportBillDetail(PB_TransportBillDetailDTO data)
        {
            return await _pB_TransportBillBus.UnloadTransportBillDetailAsync(data);
        }

        /// <summary>
        /// 车辆毛重超载卸车扫描单个物料
        /// </summary>
        /// <param name="billId">派车单Id</param>
        /// <param name="qrcode">单个物料二维码</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<TransportBillDetailMaterialDTO> GetBillDetailMaterialData(string billId, string qrcode)
        {
            return await _pB_TransportBillBus.GetBillDetailMaterialDataAsync(billId, qrcode);
        }

        [HttpPost]
        public async Task<List<ProjectReturnSelection>> GetTransportBillReturnId(string Id) {
            var list = await _pB_TransportBillBus.GetTransportBillReturnId(Id);
            return list;
        }
        /// <summary>
        /// 车辆毛重超载卸车移除
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteUnloadBillDetail(BillUnloadDTO data)
        {
            await _pB_TransportBillBus.DeleteUnloadBillDetailAsync(data);
        }

        /// <summary>
        /// 现场验收提交
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task CheckDingBillDTO(DingBillDTO data) {
            await _pB_TransportBillBus.CheckDingBillDTO(data);
        }

        /// <summary>
        /// 钉钉获取某项目装车数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<DingTransportBillModel>> GetDingTransportBillModel(PageInput<DingTransportBillSearch> input) {
          return  await _pB_TransportBillBus.GetDingTransportBillModel(input);
        }
        /// <summary>
        /// 钉钉收货扫描当前项目下的派车单
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="billqrcode"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDTO> GetDingBillListDataAsync(string ProjectId, string billqrcode) {
            var lis = await _pB_TransportBillBus.GetDingBillListDataAsync(ProjectId,billqrcode);
            return lis;        }
        #region 外协装车



        /// <summary>
        /// 外协发获取车辆信息,/ 外协回货获取车辆信息
        /// </summary>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_TransportBillVehicleDTO>> GetoutCarInformation(string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetoutCarInformationAsync(deptId, BillType);
        }

        /// <summary>
        /// 根据车牌获取车辆信息
        /// </summary>
        /// <param name="plateno">车牌</param>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDetailDTO> GetOutTransportBillData(string plateno, string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetOutTransportBillDataAsync(plateno, deptId, BillType);
        }


        /// <summary>
        /// 卸车根据车牌获取车辆信息
        /// </summary>
        /// <param name="plateno">车牌</param>
        /// <param name="deptId">登录人组织Id</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDetailDTO> GetInOutTransportBillData(string plateno, string deptId, string BillType)
        {
            return await _pB_TransportBillBus.GetInOutTransportBillDataAsync(plateno, deptId, BillType);
        }









        /// <summary>
        /// 外协扫描装车
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddOutTransportBillDetail(PB_TransportBillDetailDTO data)
        {
            await _pB_TransportBillBus.AddOutTransportBillDetailAsync(data);
        }


        /// <summary>
        /// 删除车辆已装车的明细,(外协减库存)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteOutTransportBillDetail(PB_TransportBillDetailListData data)
        {
            await _pB_TransportBillBus.DeleteeOutTransportBillDataDetailAsync(data);


        }



        /// <summary>
        /// 完成装车,并且生成出库单据
        /// </summary>
        /// <param name="billId">车id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task CompleteOutTransportBill(string billId)
        {
            await _pB_TransportBillBus.CompleteOutTransportBillAsync(billId);
        }



        #endregion


        #region 外包回货装车

        /// <summary>
        /// 外协回货取车辆信息
        /// </summary>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_TransportBillVehicleDTO>> GetIntCarInformation(string BillType)
        {
            return await _pB_TransportBillBus.GetInCarInformationAsync( BillType);
        }

        /// <summary>
        /// 根据车牌获取回货车辆信息
        /// </summary>
        /// <param name="plateno">车牌</param>
        /// <param name="BillType">车辆类型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_TransportBillDataDetailDTO> GetInTransportBillData(string plateno, string BillType)
        {
            return await _pB_TransportBillBus.GetInTransportBillDataaAsync(plateno, BillType);
        }




        /// <summary>
        /// 外包回货装车
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddBackTransportBillDetail(PB_TransportBillDetailDTO data)
        {
            await _pB_TransportBillBus.AddBackTransportBillDetailAsync(data);
        }


        #endregion

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_TransportBill data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_TransportBillBus.AddDataAsync(data);
            }
            else
            {
                await _pB_TransportBillBus.UpdateDataAsyncs(data);
            }
        }


        /// <summary>
        /// 皮重过磅
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdateEmpty(PB_TransportBill data)
        {

            //data.WeighingPeople = _Op.UserId;
                await _pB_TransportBillBus.Empty(data);
        }
        /// <summary>
        /// 毛重过磅
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdateRoughweight(PB_TransportBill data)
        {

           // data.WeighingPeople = _Op.UserId;
            await _pB_TransportBillBus.Roughweight(data);

        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_TransportBillBus.DeleteDataAsync(ids);
        }

        [HttpPost]
        public async Task SavePlantData(PB_TransportBill data)
        {
            await _pB_TransportBillBus.UpdateDataAsync(data);
        }
        [HttpPost]
        public async Task<PageResult<PB_ProjectDelivery>> GetProjectDeliveryList(PageInput<DingTransportBillSearch> input) {
            var res = await _pB_TransportBillBus.GetProjectDeliveryList(input);
            return res;
        }
        [HttpPost]
        [NoCheckJWT]
        public async Task<IActionResult> GetExportList(PageInput<DingTransportBillSearch> input)
        {
          var res = await _pB_TransportBillBus.GetProjectDeliveryList(input);
            HSSFWorkbook book = new HSSFWorkbook();
            ISheet s1 = book.CreateSheet("项目发货汇总");
            IRow r1 = s1.CreateRow(0);
            r1.CreateCell(0).SetCellValue("项目");
            r1.CreateCell(1).SetCellValue("车牌");
            r1.CreateCell(2).SetCellValue("发货状态");
            r1.CreateCell(3).SetCellValue("发货日期");
            r1.CreateCell(4).SetCellValue("发货数量");
            r1.CreateCell(5).SetCellValue("状态");
            r1.CreateCell(6).SetCellValue("签收日期");
            r1.CreateCell(7).SetCellValue("签收数量");
            r1.CreateCell(8).SetCellValue("签收人");
            for (int i = 0; i < res.Data.Count; i++)
            {
                IRow rt = s1.CreateRow(i + 1);
                rt.CreateCell(0).SetCellValue  (res.Data[i].Abstract);
                rt.CreateCell(1).SetCellValue(res.Data[i].PlateNO);
                rt.CreateCell(2).SetCellValue(res.Data[i].State);
                rt.CreateCell(3).SetCellValue(res.Data[i].DepartureTime);
                rt.CreateCell(4).SetCellValue(Convert.ToDouble(res.Data[i].OutNum == null ? 0 : Convert.ToDouble(res.Data[i].OutNum.ToString())));
                rt.CreateCell(5).SetCellValue(res.Data[i].GetState);
                rt.CreateCell(6).SetCellValue(res.Data[i].ReceivingTime);
                rt.CreateCell(7).SetCellValue(Convert.ToDouble(res.Data[i].GetNum == null ? 0 : Convert.ToDouble(res.Data[i].GetNum.ToString())));
                rt.CreateCell(8).SetCellValue(res.Data[i].ReceivingUserName);
            }
            //输出的文件名称
            string fileName = "项目发货汇总" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + ".xls";
            //把Excel转为流，输出
            //创建文件流
            System.IO.MemoryStream bookStream = new System.IO.MemoryStream();
            //将工作薄写入文件流
            book.Write(bookStream);

            //输出之前调用Seek（偏移量，游标位置) 把0位置指定为开始位置
            bookStream.Seek(0, System.IO.SeekOrigin.Begin);
            //Stream对象,文件类型,文件名称
            return File(bookStream, "application/vnd.ms-excel", fileName);



        }
        /// <summary>
        /// 收货扫描成品
        /// </summary>
        /// <param name="billqrcode"></param>
        /// <param name="Jobcode"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UnloadScanfinished(string billqrcode, string Jobcode) {
            await _pB_TransportBillBus.UnloadScanfinished(billqrcode,Jobcode);
        }

        /// <summary>
        /// 钉钉查看装车单明细数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<See_TransportBill>> GetSee_TransportBillList(string id) {
            var listdata = await _pB_TransportBillBus.GetSee_TransportBillList(id);
            return listdata;
        }
        /// <summary>
        /// 钉钉查看装车单明细数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<See_TransportBill>> GetSee_TransportBillListDetail(string id)
        {
            var listdata = await _pB_TransportBillBus.GetSee_TransportBillListDetail(id);
            return listdata;
        }
        /// <summary>
        /// 钉钉扫描包弹出包信息
        /// </summary>
        /// <param name="PackQrCode">包二维码</param>
        /// <param name="BillId">派车单号</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ReceivePackDto> GetReceivePackDataAsync(string PackQrCode, string BillId) {
            return await _pB_TransportBillBus.GetReceivePackDataAsync(PackQrCode,BillId);
        }
        #endregion

        #region 备装异常

        /// <summary>
        /// 获取备装异常数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<PB_TransportBillDTO>> GetDataAbnormalList(PageInput<BilldConditionDTO> input)
        {
            return await _pB_TransportBillBus.GetDataAbnormalListAsync(input);
        }

        /// <summary>
        /// 获取装车异常的明细
        /// </summary>
        /// <param name="BillId">派车单Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<TransportBillDetailAbnormal>> GetTransportBillDetailAbnormalList(string BillId)
        {
            return await _pB_TransportBillBus.GetTransportBillDetailAbnormalListAsync(BillId);
        }

        /// <summary>
        /// 异常处理(生成出库单据)
        /// </summary>
        /// <param name="BillId">派车单Id</param>
        /// <returns></returns>
        [HttpPost]
        public async Task ExceptionHandling(string BillId)
        {
            await _pB_TransportBillBus.ExceptionHandlingAsync(BillId);
        }

        #endregion

    }
}